﻿using System;
using System.Collections;
using System.Dynamic;
using System.Security.Cryptography.X509Certificates;
using System.Security.Policy;
using System.Xml.Schema;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Net.Mime;
using ConsoleApplication1;

namespace ConsoleApplication1
{
    class Boxtester
    {
        static void Main(string[] args)
        {
            
            
            Console.WriteLine("伴随着雷鸣于风暴降生的勇士，如今已经准备踏上新的征途……");
            Console.WriteLine("勇士之名为……");
            string name = "";
            name = Console.ReadLine();
            Console.WriteLine("正在生成勇士的资料...");
            int power = 0;
            int life = 100;
            int wisdom = 50;
            string job = "";
            int height = 100;
            int weight = 150;
            int magicpower = 50;
            int money = 0;

            List<Items> pack=new List<Items>();
            
            Random ra = new Random();
            power = ra.Next(10, 100);
            life = ra.Next(100, 300);
            wisdom = ra.Next(20, 300);
            height = ra.Next(40, 220);
            weight = ra.Next(60, 300);
            magicpower = ra.Next(30, 200);
            money = ra.Next(50, 1000);
            

            string[] joblist = {"剑士","元素魔法师","术士","行僧","行商"};
            job = joblist[ra.Next(0, joblist.Length)];
            int[] jobchange = new int[7];
            if (job == "剑士")
            {
                jobchange[0] = 6;
                jobchange[1] = 20;
                jobchange[2] = 5;
                jobchange[3] = 10;
                jobchange[4] = 2;
                jobchange[5] = -15;
                jobchange[6] = 0;//金钱加成
                
            }else if (job == "元素魔法师")
            {
                jobchange[0] = -3;//力量加成         
                jobchange[1] = -2;//生命加成
                jobchange[2] = 15;//智慧加成
                jobchange[3] = 0;//身高加成
                jobchange[4] = 0;//体重加成
                jobchange[5] = 20;//魔力加成
                jobchange[6] = 0;//金钱加成
            }else if (job == "术士")
            {
                jobchange[0] = 2;//力量加成         
                jobchange[1] = 5;//生命加成
                jobchange[2] = 13;//智慧加成
                jobchange[3] = 3;//身高加成
                jobchange[4] = 0;//体重加成
                jobchange[5] = -5;//魔力加成
                jobchange[6] = 0;//金钱加成
            }else if (job == "行僧")
            {
                jobchange[0] = 8;//力量加成         
                jobchange[1] = 10;//生命加成
                jobchange[2] = 5;//智慧加成
                jobchange[3] = 0;//身高加成
                jobchange[4] = 0;//体重加成
                jobchange[5] = -8;//魔力加成
                jobchange[6] = 0;//金钱加成
            }else if (job == "行商")
            {
                jobchange[0] = 5;//力量加成         
                jobchange[1] = 5;//生命加成
                jobchange[2] = 20;//智慧加成
                jobchange[3] = 0;//身高加成
                jobchange[4] = 0;//体重加成
                jobchange[5] = -15;//魔力加成
                jobchange[6] = 500;//金钱加成
            }

            power += jobchange[0];
            life += jobchange[1];
            wisdom += jobchange[2];
            height += jobchange[3];
            weight += jobchange[4];
            magicpower += jobchange[5];
            int[] player_point = {power,life,wisdom,height,weight,magicpower,money};

            Console.Write("勇士，你的档案如下：\n"+"名号："+name+"\n职业："+job+"\n最大生命："+life+"("+jobchange[1]+")"+"\n力量："+power+"("+jobchange[0]+")"+"\n智慧："+wisdom+"("+jobchange[2]+")"+"\n身高："+height+"("+jobchange[3]+")"+"\n体重："+weight+"("+jobchange[4]+")"+"\n魔法力量："+magicpower+"("+jobchange[5]+")"+"\n金钱："+money+"("+jobchange[6]+")");
            SortedList player = new SortedList();
            player.Add("power",power);
            player.Add("life",life);
            player.Add("wisdom",wisdom);
            player.Add("height",height);
            player.Add("weight",weight);
            player.Add("magicpower",magicpower);
            player.Add("job",job);
            player.Add("pos_city","");
            Console.Write("\n=======进入游戏========");
            Console.Write("\n愿光辉照耀你的前路！你的传奇将在何处开始？\n");
            Console.Write("1.圣洛兰兹城\n2.凯罗城\n3.黑曜城\n");
            City playerpos=new City(0,"",new string[]{},new List<Npcs>(),new List<Monster>());
            string playeraction;
            
            
            City shengluolanzi=new City(1,"圣洛兰兹城",new string[]{"市政厅",
                "酒馆",
                "铁匠铺",
                "偏僻市区",
                "闹市区",
                "中心市区"},
                new List<Npcs>(),
                new List<Monster>());
            
        
            City kailuo=new City(2,"凯罗城",new string[]{"市政厅",
                "灰鹰酒馆",
                "塔塔裁缝店"},
                new List<Npcs>(),
                new List<Monster>() );
            
            City heiyao=new City(3,"黑曜城",new string[]{"市政厅",
                "灰熊酒馆",
                "黑胡椒市场"},
                new List<Npcs>(),
                new List<Monster>());

            List<Npcs> npclist = new List<Npcs>(){
                new Npcs(1, "罗德", "Rode", shengluolanzi, "市政厅"),
                new Npcs(2, "凯西", "Kicy", shengluolanzi, "酒馆"),
                new Npcs(3, "罗根", "Logen", kailuo, "灰鹰酒馆"),
                new Npcs(4, "麦卡锡", "McCarthy", shengluolanzi, "偏僻市区"),
                new Npcs(5, "约瑟夫", "Joseph", shengluolanzi, "闹市区"),
                new Npcs(6, "布朗", "Brown", shengluolanzi, "中心市区"),
                new Npcs(7, "埃文斯", "Evans", shengluolanzi, "铁匠铺")
            };;

            for (int l = 0; l < npclist.Count; l++)
            {
                if (npclist[l].Npccity == shengluolanzi)
                {
                    shengluolanzi.Npcs.Add(npclist[l]);
                }else if (npclist[l].Npccity == kailuo)
                {
                    kailuo.Npcs.Add(npclist[l]);
                }
            }
            playeraction = Console.ReadLine();
            if (playeraction == "1")
            {
                game(player_point,playerpos,pack);
            }else if (playeraction == "2")
            {
                playerpos = kailuo;
                game(player_point,playerpos,pack);
            }else if (playeraction == "3")
            {
                playerpos = heiyao;
                game(player_point,playerpos,pack);
            }
        }

        static int _gametimehour=0;
        static int _gametimeday = new Random().Next(100,999);
        public static void game(int[] player,City playerpos,List<Items> pack)
        {
            int eventid;
            Random rd=new Random(int.Parse(DateTime.Now.ToString("HHmmssfff")));
            int city_area_id=rd.Next(0,playerpos.Areas.Length);
            string city_area = playerpos.Areas[city_area_id];
            string[] playeraction = new string[] {"随便走走","打开背包","更换装备","查看资料","打开地图","npc互动","游戏选项"};
            string playeractionnum;
            while (player[1]>0)
            {
                Console.Clear();
                Console.Write("生命值："+player[1]+" 力量："+player[0]+" 智慧："+player[2]+" 身高："+player[3]+" 体重："+player[4]+" 魔力："+player[5]+" 金钱："+player[6]+"\n");
                Console.Write(playerpos.Name+"->"+city_area+"====|"+"时间:"+_gametimehour+"-"+_gametimeday+"|===="+"\n");
                for (int j = 0; j < playerpos.Npcs.Count; j++)
                {
                    if (playerpos.Npcs[j].Npcpos == city_area)
                    {
                        Console.Write("当前区域NPC："+playerpos.Npcs[j].Name+"\n");
                    }
                }
                Console.WriteLine("\n====================");
                for (int k = 0; k < playeraction.Length; k++)
                {
                    Console.Write((k+1).ToString()+"."+playeraction[k]+"##");
                }
                Console.WriteLine();
                playeractionnum = Console.ReadLine();
                if (playeractionnum == "1")
                {
                    if (_gametimehour == 23)
                    {
                        _gametimehour = 1;
                        _gametimeday += 1;
                    }
                    else
                    {
                        _gametimehour += 2;
                    }
                    eventid = rd.Next(0, 4);
                    switch (eventid)
                    {
                        case 0:
                            int addmoney = rd.Next(1, 100);
                            Console.WriteLine("你捡到了"+addmoney+"块钱!");
                            player[6] += addmoney;
                            Console.Write("你现在有："+player[6]+"块钱");
                            break;
                        case 1:
                            double money = player[6];
                            int countmoney = rd.Next(1, Convert.ToInt32(money*0.5));
                            Console.WriteLine("你丢掉了"+countmoney+"块钱！");
                            player[6] -= countmoney;
                            Console.Write("你现在有："+player[6]+"块钱");
                            break;
                        case 2:
                            Console.WriteLine("什么也没发生。");
                            break;
                        case 3:   
                            int helpman_num = rd.Next(0, 3);
                            string[] helpman = {"衣衫褴褛","平平无奇","珠光宝气"};
                            Console.WriteLine("一个"+helpman[helpman_num]+"的人向你问路...");
                            Console.WriteLine("1.告诉他 2.说你不知道");
                            playeractionnum = Console.ReadLine();
                            if (playeractionnum == "1" && helpman_num == 0)
                            {
                                Console.WriteLine("衣衫褴褛的人是位高阶法师，给予你所有属性5点加成！");
                                for (int i = 0; i < 5; i++)
                                {
                                    player[i] += 5;
                                }
                                Console.ReadKey();
                            }else if (playeractionnum == "1" && helpman_num == 1)
                            {
                                Console.WriteLine("他对你说了声谢谢后走了");
                                //Console.ReadKey();
                            }else if (playeractionnum == "1" && helpman_num == 2)
                            {
                                int helpmangive = rd.Next(20, 250);
                                Console.WriteLine("他给了你"+helpmangive.ToString()+"块钱");
                                player[6] += helpmangive;
                                //Console.ReadKey();
                            }else if (playeractionnum == "2" && helpman_num == 0)
                            {
                                Console.WriteLine("他面色难堪地离开了");
                                //Console.ReadKey();
                            }else if (playeractionnum == "2" && helpman_num == 1)
                            {
                                Console.WriteLine("这人是地下黑帮头目，他记住你了");
                                //Console.ReadKey();
                            }else if (playeractionnum == "2" && helpman_num == 2)
                            {
                                Console.WriteLine("他傲慢地离开了");
                                //Console.ReadKey();
                            }
                            break;
                    }
                    Console.ReadKey();
                }else if (playeractionnum == "2")
                {
                    Console.WriteLine("背包\n====================");
                    for (int i = 0; i < pack.Count; i++)
                    {
                        Console.Write("\n");
                        Console.Write(pack[i].Name);
                    }
                    Console.WriteLine("====================");
                    Console.ReadKey();
                }else if (playeractionnum == "6")
                {
                    
                }
                else if (playeractionnum == "7")
                {
                    Console.Write("1.退出游戏\n");
                    playeractionnum = Console.ReadLine();
                    if (playeractionnum == "1")
                    {
                        Environment.Exit(0);
                    }
                }
            }
        }
        
    }
}

